import Base from "./base";
const tableName = `admin_user`;
export default class extends Base {
  static get _REST() {
    return false;
  }
 
  async listAction() {
    const page = this.get("page") || 1;
    const size = this.get("size") || 10;
    const name = this.get("name") || "";
    const model = this.model(tableName);
    const filed = `id,username,nickname,admin_role_ids,sort,is_super,is_disable,login_num,create_time,login_time,update_time`;
    const data = await model
      .field(filed)
      .where({ username: ["like", `%${name}%`] })
      .order("id DESC") 
      .page(page, size)
      .countSelect();

    return this.success(data);
  }
  async infoAction() {
    const userId = this.getLoginUserId();
    const admin = await this.model(tableName).where({ id: userId }).find();
    delete admin.password;
    return this.success(admin);
  }
}
